<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        // function once (fn) {
        //     var called = false;
        //     return function () {
        //         if (!called) {
        //         called = true;
        //         fn.apply(this, arguments);
        //         }
        //     }
        // }
        // function dosomeThings(){
        //     console.log("执行了")
        // }
        // once(dosomeThings())\
        // let path = '2.we.c.sd.se'
        // function parsePath (path) {
        //     var segments = path.split('.');
        //     console.log(segments)
        //     return function (obj) {
        //         for (var i = 0; i < segments.length; i++) {
        //         console.log(obj)
        //         if (!obj) { return }
        //         obj = obj[segments[i]];
        //         }
        //         return obj
        //     }
        // }
        // console.log(parsePath(path)({hello:'sdsd'}))

        // var hasProto = '__proto__' in {}
        // console.log(hasProto)
        // console.log('__proto__' in Object)
        // console.log('__proto__' in Array)
        // console.log()

        // const anObj = { 100: 'a',6:'o', 2: 'b', 7: 'c' };
        // console.log(Object.keys(anObj)); // console: ['2', '7', '100']
        function SetManager(name) {
            this.manager = name;
        }

        SetManager.prototype.getName = function() {
            console.log(this.manager);
        };        
        var SingletonSetManager = (function() {
            var manager = null;
            console.log('11111')
            return function(name) {
                if (!manager) {
                    manager = new SetManager(name);
                }
                console.log(manager)
                return manager;
            } 
        })()
        //这个命名之后的括号就是定义并且立即执行

    </script>
</body>
</html>